const {
  DataTypes
} = require('sequelize');
module.exports = sequelize => {
  const attributes = {
    id: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: null,
      primaryKey: true,
      autoIncrement: true,
      comment: "自增id",
      field: "id"
    },
    user_id: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "用户id",
      field: "user_id"
    },
    order_id: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "订单id",
      field: "order_id"
    },
    goods_id: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "商品id",
      field: "goods_id"
    },
    title: {
      type: DataTypes.CHAR(160),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "标题",
      field: "title"
    },
    images: {
      type: DataTypes.CHAR(255),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "封面图片",
      field: "images"
    },
    original_price: {
      type: DataTypes.DECIMAL,
      allowNull: false,
      defaultValue: "0.00",
      primaryKey: false,
      autoIncrement: false,
      comment: "原价",
      field: "original_price"
    },
    price: {
      type: DataTypes.DECIMAL,
      allowNull: false,
      defaultValue: "0.00",
      primaryKey: false,
      autoIncrement: false,
      comment: "价格",
      field: "price"
    },
    total_price: {
      type: DataTypes.DECIMAL,
      allowNull: false,
      defaultValue: "0.00",
      primaryKey: false,
      autoIncrement: false,
      comment: "当前总价(单价*数量)",
      field: "total_price"
    },
    spec: {
      type: DataTypes.TEXT,
      allowNull: true,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "规格",
      field: "spec"
    },
    buy_number: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "购买数量",
      field: "buy_number"
    },
    model: {
      type: DataTypes.CHAR(30),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "型号",
      field: "model"
    },
    spec_weight: {
      type: DataTypes.DECIMAL,
      allowNull: false,
      defaultValue: "0.00",
      primaryKey: false,
      autoIncrement: false,
      comment: "重量（kg）",
      field: "spec_weight"
    },
    spec_volume: {
      type: DataTypes.DECIMAL,
      allowNull: false,
      defaultValue: "0.00",
      primaryKey: false,
      autoIncrement: false,
      comment: "体积（m³）",
      field: "spec_volume"
    },
    spec_coding: {
      type: DataTypes.CHAR(80),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "编码",
      field: "spec_coding"
    },
    spec_barcode: {
      type: DataTypes.CHAR(80),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "条形码",
      field: "spec_barcode"
    },
    refund_price: {
      type: DataTypes.DECIMAL,
      allowNull: false,
      defaultValue: "0.00",
      primaryKey: false,
      autoIncrement: false,
      comment: "退款金额",
      field: "refund_price"
    },
    returned_quantity: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "退货数量",
      field: "returned_quantity"
    },
    add_time: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "添加时间",
      field: "add_time"
    },
    upd_time: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "更新时间",
      field: "upd_time"
    }
  };
  const options = {
    tableName: "sxo_order_detail",
    comment: "",
    indexes: [{
      name: "user_id",
      unique: false,
      type: "BTREE",
      fields: ["user_id"]
    }, {
      name: "order_id",
      unique: false,
      type: "BTREE",
      fields: ["order_id"]
    }, {
      name: "goods_id",
      unique: false,
      type: "BTREE",
      fields: ["goods_id"]
    }]
  };
  const SxoOrderDetailModel = sequelize.define("sxo_order_detail_model", attributes, options);
  return SxoOrderDetailModel;
};